<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">

      <el-form-item label="当前日期" prop="curDate">
        <el-date-picker clearable v-model="queryParams.curDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="preWorkheaderList" height="calc(100vh - 230px)">
      <el-table-column label="序号" align="center" width="50px">
        <template slot-scope="scope">
          <span>{{scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="日期" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <!-- <span>{{ parseTime(scope.row.curDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span> -->
          <span>{{ scope.row.createTime}}</span>
        </template>
      </el-table-column>
      <el-table-column label="工单编号" align="center" prop="workorderCode" />
      <el-table-column label="工序编号" align="center" prop="processCode" />
      <el-table-column label="工序名称" align="center" prop="processName" />
      <el-table-column label="产品编号" align="center" prop="itemCode" />
      <el-table-column label="产品名称" align="center" prop="itemName" />
      <el-table-column label="规格型号" align="center" prop="specification" />
      <el-table-column label="车间名称" align="center" prop="workshopCode" />
      <el-table-column label="产线名称" align="center" prop="lineName" />
      <el-table-column label="工位编号" align="center" prop="workstationCode" />
      <el-table-column label="物料备料" align="center" prop="materialPreparationName" />
      <el-table-column label="辅料备料" align="center" prop="auxiliaryPreparationName" />
      <el-table-column label="设备运行状态" align="center" prop="runningStateName" />
      <el-table-column label="工装" align="center" prop="frockName" />

    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

  </div>
</template>

<script>
import { listPreWorkheader } from "@/api/mes/pro/preWorkheader";
export default {
  name: "PreWorkheader",
  dicts: ['mes_workorder_status'],
  data() {
    return {

      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产领料单头表格数据
      preWorkheaderList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        curDate: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询生产领料单头列表 */
    getList() {
      this.loading = true;
      listPreWorkheader(this.queryParams).then(response => {
        this.preWorkheaderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },


  }
};
</script>
